package com.cqjtu.tto.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.stp.StpUtil;
import com.cqjtu.tto.service.LoginService;
import com.cqjtu.tto.vo.Results;
import com.cqjtu.tto.vo.params.LoginParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author：monkey-L
 * @description: 登录
 * @date: 9:28 2021/12/7
 */
@RestController
@Api(tags = "登录注销模块")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("toLogin")
    @ApiOperation(value = "用户登录")
    public Results login(@RequestBody LoginParam loginParam) {
        return loginService.login(loginParam);
    }

    @PostMapping("logout")
    @ApiOperation(value = "退出登录")
    public Results logout() {
        StpUtil.logout();
        return Results.success("退出登录成功！");
    }
//    "departmentName":"后勤部1",
//            "departmentResponsibleContent":"负责一切后勤事务",
//            "oldDepartmentName":"后勤部"
}
